namespace KinonekoSoftware.CodariaDB.Core
{
    public abstract class Res : RootObject
    {

    }

    public sealed class Occupation : RootObject
    {
        [BsonIgnore]
        public bool Usage { get; set; }

        public ResourceType Type     { get; init; }
        public string       FileName { get; init; }
    }

    public sealed class Resource : RootObject, IEquatable<Resource>
    {
        public int      Height   { get; init; }
        public int      Width    { get; init; }
        public string   FileName { get; init; }
        public DateTime Duration { get; init; }
        public bool     Usage    { get; set; }

        public required string       ImageID { get; init; }
        public required ResourceType Type    { get; init; }


        public bool Equals(Resource other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return ImageID == other.ImageID && Type == other.Type;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != GetType()) return false;
            return Equals((Resource)obj);
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(ImageID, (int)Type);
        }
    }
}